/*************************************************************************
	> File Name: P1109.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-09 09:37:34
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 50

int arr[MAX_N + 5];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int L, R;
    cin >> L >> R;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += arr[i];
    }
    if (sum < L * n || sum > R * n) {
        cout << -1 << endl;
    } else {
        int cnt_l = 0, cnt_r = 0;
        for (int i = 1; i <= n; i++) {
            if (arr[i] > R) cnt_r += arr[i] - R;
            if (arr[i] < L) cnt_l += L - arr[i];
        }
        cout << (cnt_l > cnt_r ? cnt_l : cnt_r) << endl;
    }
    return 0;
}
